package com.shuzixiangcun.controller.admin;

import com.shuzixiangcun.entity.Xiangcunchanyei;

import com.shuzixiangcun.service.admin.XiangcunchanyeiServiceImpl;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 乡村产业表(Xiangcunchanyei)表控制层
 *
 * @author makejava
 * @since 2024-06-24 08:26:18
 */
@RestController
@RequestMapping("admin/xiangcunchanyei")
public class XiangcunchanyeiController {
    /**
     * 服务对象
     */
    @Resource
    private XiangcunchanyeiServiceImpl xiangcunchanyeiService;



    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<Xiangcunchanyei> queryById(@PathVariable("id") Object id) {
        return ResponseEntity.ok(this.xiangcunchanyeiService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param xiangcunchanyei 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<Xiangcunchanyei> add(Xiangcunchanyei xiangcunchanyei) {
        return ResponseEntity.ok(this.xiangcunchanyeiService.insert(xiangcunchanyei));
    }

    /**
     * 编辑数据
     *
     * @param xiangcunchanyei 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<Xiangcunchanyei> edit(Xiangcunchanyei xiangcunchanyei) {
        return ResponseEntity.ok(this.xiangcunchanyeiService.update(xiangcunchanyei));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Object id) {
        return ResponseEntity.ok(this.xiangcunchanyeiService.deleteById(id));
    }

}

